<?php
namespace app\index\controller;
use think\Db;

class Index extends Base
{
	public function initialize(){
	    parent::initialize();
	}
    public function index()
    {
		$article_list = $this->getArticle();
		$this->assign('article',$article_list);
		$this->assign('article_tag',1);
		return $this->fetch();
    }
	protected function getArticle($limit=10){
		
		$page = request()->param('page');
		$list = Db::name('article')->where('status',1)->paginate($limit)->each(function($item, $key){
			$item['url'] = url('article/index',['id'=>$item['id']]);
			$item['tag'] = $this->getTagList($item['tag']);
			return $item;
		});
		$res['data'] = $list->items();;
		$res['page'] = $list->render();
		return $res;
	}
}
